package com.ruoyi.datastatistics.service.impl;

import com.ruoyi.common.utils.DateUtil;
import com.ruoyi.datastatistics.domain.TerminalHistoryData;
import com.ruoyi.datastatistics.mapper.TerminalHistoryDataMapper;
import com.ruoyi.datastatistics.service.ITerminalHistoryDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 大-历史数据Service业务层处理
 *
 * @author ruoyi
 * @date 2023-09-06
 */
@Service
public class TerminalHistoryDataServiceImpl implements ITerminalHistoryDataService {
    @Autowired
    private TerminalHistoryDataMapper terminalHistoryDataMapper;

    /**
     * 查询大-历史数据
     *
     * @param TerminalID 大-历史数据主键
     * @return 大-历史数据
     */
    @Override
    public TerminalHistoryData selectTerminalHistoryDataByTerminalID(String TerminalID) {
        return terminalHistoryDataMapper.selectTerminalHistoryDataByTerminalID(TerminalID);
    }

    /**
     * 查询大-历史数据列表
     *
     * @param terminalHistoryData 大-历史数据
     * @return 大-历史数据
     */
    @Override
    public List<TerminalHistoryData> selectTerminalHistoryDataList(TerminalHistoryData terminalHistoryData) throws ParseException {
        SimpleDateFormat foramt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startTime = foramt.parse(DateUtil.past7Days());
//        terminalHistoryData.setCreateDate(startTime);
        return terminalHistoryDataMapper.selectTerminalHistoryDataList(terminalHistoryData);
    }


    @Override
    public List<TerminalHistoryData> getTerminalHistoryDataList(String locationNb, String startTime, String endTime,String maxTime,Long maxId) throws ParseException {
        return terminalHistoryDataMapper.getTerminalHistoryDataList(locationNb, startTime, endTime,maxTime,maxId);
    }


    /**
     * 新增大-历史数据
     *
     * @param terminalHistoryData 大-历史数据
     * @return 结果
     */
    @Override
    public int insertTerminalHistoryData(TerminalHistoryData terminalHistoryData) {
        return terminalHistoryDataMapper.insertTerminalHistoryData(terminalHistoryData);
    }

    /**
     * @param list
     * @return
     */
    @Override
    public int batchinsertTerminalHistoryData(List<TerminalHistoryData> list) {
        return terminalHistoryDataMapper.batchinsertTerminalHistoryData(list);
    }

    /**
     * 修改大-历史数据
     *
     * @param terminalHistoryData 大-历史数据
     * @return 结果
     */
    @Override
    public int updateTerminalHistoryData(TerminalHistoryData terminalHistoryData) {
        return terminalHistoryDataMapper.updateTerminalHistoryData(terminalHistoryData);
    }

    /**
     * 批量删除大-历史数据
     *
     * @param TerminalIDs 需要删除的大-历史数据主键
     * @return 结果
     */
    @Override
    public int deleteTerminalHistoryDataByTerminalIDs(String[] TerminalIDs) {
        return terminalHistoryDataMapper.deleteTerminalHistoryDataByTerminalIDs(TerminalIDs);
    }

    /**
     * 删除大-历史数据信息
     *
     * @param TerminalID 大-历史数据主键
     * @return 结果
     */
    @Override
    public int deleteTerminalHistoryDataByTerminalID(String TerminalID) {
        return terminalHistoryDataMapper.deleteTerminalHistoryDataByTerminalID(TerminalID);
    }
}
